import request from "@/utils/request";
import { stringify } from "qs";
// 查询平台店铺列表
export async function queryShopList(params) {
	const data = { current: 1, size: 100, ...params };
	return request(`/blade-goods/newSystem/ecStore/list/page`, {
		method: "POST",
		data: data
	});
}

// 查询奇门店铺列表
export async function queryQimenShopList(params) {
	const data = { current: 1, size: 100, ...params };
	return request(`/blade-goods/jushuitanstore/page`, {
		method: "POST",
		data: data
	}).then(res => {
		if (!res?.data?.records) {
			return res;
		}

		// 兼容上面的平台列表
		res.data.records = res.data.records.map(item => {
			item.type = item.type || 13;
			item.storeId = item.storeId || item.shopId;
			item.storeName = item.storeName || item.shopName;
			item.typeName = item.typeName || "奇门";

			return item;
		});

		return res;
	});
}

// 获取关联sku的店铺商品所属店铺信息
export async function getStoreInfoBySkuIds(params) {
	return request(`/new-goods/goods/sku/get-store-info-by-sku-ids`, {
		method: "POST",
		data: params,
		loading: true
	});
}
// 获取关联spu的店铺商品所属店铺信息
export async function getStoreInfoBySpuIds(params) {
	return request(`/new-goods/goods/spu/get-store-info-by-spu-ids`, {
		method: "POST",
		data: params,
		loading: true
	});
}
// 库存同步至店铺
export async function skuSyncStockToStore(params) {
	return request(`/new-goods/goods/sku/sync-stock-to-store`, { method: "POST", data: params, loading: true });
}
export async function spuSyncStockToStore(params) {
	return request(`/new-goods/goods/spu/sync-stock-to-store`, { method: "POST", data: params, loading: true });
}
